package tw.rescue.model.slim3.model;

import java.io.Serializable;
import java.util.Date;
import java.util.List;

import org.slim3.datastore.Attribute;
import org.slim3.datastore.Model;

import com.google.appengine.api.datastore.Key;

/**
 * 帳號，一個 Identity 可能有一至多個 Account，Account entity 亦儲存於 Identity KIND，並且以
 * 一個 identity entity 做為其 parent
 */
@Model(schemaVersion = 1)
public class Account extends BaseModel implements Serializable {

	public final static String KIND = "Account";
    private static final long serialVersionUID = 1L;

	@Attribute(primaryKey = true)
	private Key key;

	@Attribute(version = true)
    private Long version;

	private String nickname; // 使用者匿稱
	private String password; // 密碼
	private String email; // email (User 和 Admin 都以 email 做為帳號，但顯示時 user 僅顯示 @ 前的部份文字, admin 比照 google group 顯示 e-mail 方式)
	private Date lastAccess;  //最近一次存取時間
	private Date lastAuth;  //最近一次認證時間
	private boolean isAdmin; // 是否為管理者
	private List<Key> messages; //需要包含所發布的message嗎? 

	public void setKey(Key key) {
		this.key = key;
	}

	public Key getKey() {
		return key;
	}

	public void setVersion(Long version) {
		this.version = version;
	}

	public Long getVersion() {
		return version;
	}

	public String getNickname() {
		return nickname;
	}

	public void setNickname(String nickname) {
		this.nickname = nickname;
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public String getEmail() {
		return email;
	}

	public void setEmail(String email) {
		this.email = email;
	}

	public void setLastAccess(Date lastAccess) {
		this.lastAccess = lastAccess;
	}

	public Date getLastAccess() {
		return lastAccess;
	}

	public void setLastAuth(Date lastAuth) {
		this.lastAuth = lastAuth;
	}

	public Date getLastAuth() {
		return lastAuth;
	}

	public void setAdmin(boolean isAdmin) {
		this.isAdmin = isAdmin;
	}

	public boolean isAdmin() {
		return isAdmin;
	}	
	
	public void setMessages(List<Key> messages) {
		this.messages = messages;
	}
	
	public List<Key> getMessages() {
		return messages;
	}
	
	@Override
	public void format() {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void reset() {
		// TODO Auto-generated method stub
		
	}
}
